package src;

import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            int n=sc.nextInt(),sum=Integer.MIN_VALUE;
            int[]arr=new int[n];
            for (int i = 0; i < n; i++) {
                arr[i]=sc.nextInt();
            }
            for (int i = 0; i < n; i++) {
                int count=0;
                for (int j = i; j < n; j++) {
                    count+=arr[i]+arr[i+1];
                    sum=count>sum?count:sum;
                }
            }
            System.out.println(sum);
        }
    }
}
